/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-09-15
 * Time:15:17
 */
public class Demo11 {
    public static void main(String[] args) throws InterruptedException {
        //保证等待和通知是同一个对象
        Object object=new Object();
        Thread t1=new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    synchronized (object){
                        System.out.println("wait之前");
                        try {
                            object.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        System.out.println("wait之后");
                    }
                }
            }
        });

    }
}
